package cn.com.wangluotongxin.mall.controller;

import cn.com.wangluotongxin.common.constants.CommonConstant;
import cn.com.wangluotongxin.common.web.AjaxResult;
import cn.com.wangluotongxin.mall.model.MallActivityInfo;
import cn.com.wangluotongxin.mall.service.IMallActivityInfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 网络通信-商城APP-活动信息 前端控制器
 * </p>
 *
 * @author AutoGenerator
 * @since 2024-10-22
 */
@Api(tags = "网络通信-商城APP-活动信息 相关接口")
@RestController
@RequestMapping("/activity/info")
public class MallActivityInfoController {

    @Autowired
    private IMallActivityInfoService activityInfoService;

    @ApiOperation("可用活动")
    @GetMapping("/list")
    public AjaxResult<List<MallActivityInfo>> list() {
        return AjaxResult.success(activityInfoService.list(new LambdaQueryWrapper<MallActivityInfo>()
                .eq(MallActivityInfo::getIsEnabled, CommonConstant.ONE)
                .last(" order by activity_sort asc, id desc")));
    }
}